<?php 


require "../common/Curl.php";

/**
 *	https://open.esign.cn/doc/detail?id=opendoc%2Fpaas_api%2Fsgv49u&namespace=opendoc%2Fpaas_api
 * 	电子签名SaaS API非标版
 * 	签署服务API----接口顺序排列封装
 *  使用请求签名鉴权方式
 *  下一个------------------ 签署流程 sign1.php
 */



//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
 * [createFlowOneStep 一步发起签署]
 * @param  [type] $aaaa   [需要的参数]
 * @return [json]         [返回结果]
 */
function createFlowOneStep($aaaa,$appId,$secret,$url){
	$urlss = $url."/api/v2/signflows/createFlowOneStep";
	$head_url = "/api/v2/signflows/createFlowOneStep";
    $data = json_decode($aaaa,true);
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}

$aaaa = '{
 "attachments":[
        {
            "attachmentName":"1",
            "fileId":"ef08e9016806421e94f831a9d7012cb4"
        }
    ],
  "docs": [
    {
 
      "fileId": "ef08e9016806421e94f831a9d7012cb4",
      "fileName": "个人借贷合同.pdf"
 
    }
  ],
  "copiers": [
    {
      "copierAccountId": "5539bd029e4e45f4b2095aacbcf1ea19",
      "copierIdentityAccountId": "6f69dc0a5c8d415aa6a0c7e239a32241",
      "copierIdentityAccountType": 0
    }
  ],  
  "flowInfo": {
    "autoArchive": true,
    "autoInitiate": true,
    "businessScene": "创建签署流程样例",
    "contractRemind": 1,
    "contractValidity": 1601049600000,
    "flowConfigInfo": {
      "noticeDeveloperUrl": "http://101.37.27.38:1110/notice/signature",
      "noticeType": "1,2,3",
      "redirectUrl": "",
      "signPlatform": "1,2",
      "willTypes":["FACE_ZHIMA_XY"],
      "personAvailableAuthTypes":["PSN_FACEAUTH_BYURL"],
      "batchDropSeal":true,
      "orgAvailableAuthTypes":["ORG_BANK_TRANSFER"],
      "personAuthAdvancedEnabled":["PSN_BANK4_AUTHCODE"],
      "countdown":5
    },
    "remark": "",
    "signValidity": 1601049600000
  },
  "signers": [
      {
      "platformSign": true,
      "signOrder": 1,
      "signfields": [
        {
          "autoExecute": true,
          "actorIndentityType":2,
          "fileId": "ef08e9016806421e94f831a9d7012cb4",
          "posBean": {
            "posPage": "1",
            "posX": 440,
            "posY": 440
          },
          "sealType": "",
          "signDateBean": {
              "fontSize": 12,
              "format": "yyyy年MM日dd"
          },
          "signType": 1,
          "width": 150
        }
      ],
      "thirdOrderNo": "111"
    }
  ]
}';

$a = createFlowOneStep($aaaa,$appId,$secret,$url);
var_dump($a);die;
























